//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using CommunityServer.Components;
using CommunityServer.ControlPanel.Controls;
using CommunityServer.ControlPanel.UI;
using CommunityServer.Controls;
using ResourceLinkButton = CommunityServer.ControlPanel.Controls.ResourceLinkButton;
using ResourceManager = CommunityServer.ControlPanel.Components.ResourceManager;

namespace CommunityServer.ControlPanel.BlogAdmin
{
	/// <summary>
	/// Summary description for GroupForm.
	/// </summary>
	public class GroupForm : BaseBlogAdminPage
	{

		protected ResourceLinkButton SaveButton;
		protected MPContent bcr;
		protected GroupEditControl GroupEditControl1;
		
		private bool IsNew
		{
			get{return GroupEditControl1.GroupID == -1;}
		}


		override protected void OnInit(EventArgs e)
		{
			this.Load += new EventHandler(this.Page_Load);
			base.OnInit(e);
			SaveButton.Click += new EventHandler(SaveButton_Click);
		}

		
		private void Page_Load(object sender, EventArgs e)
		{
			CSContext context = CSContext.Current;
			CSContext.Current.GroupID = GroupEditControl1.GroupID = context.GetIntFromQueryString("GroupID", -1);
			GroupEditControl1.ApplicationType = ApplicationType.Weblog;

			if(IsNew)
				Head.AddTitle(ResourceManager.GetString("CP_GroupEditor_NewGroup"), this.Context);
			else
				Head.AddTitle(ResourceManager.GetString("CP_GroupEditor_EditGroup") , this.Context);
		}


		private void SaveButton_Click(object sender, EventArgs e)
		{
			if(Page.IsValid)
			{
				if(GroupEditControl1.Save())
					Modal.ClosePage(Page) ;
			}
			
		}


	}
}
